home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: HELP! How do I write to a file using Symantec C++?
- Date: 21 Jan 1996 10:33:00 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4dt4os$5gt@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe10.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 21, 1996 04:56:29 in article <HELP! How do I write to a file using
- Symantec C++?>, 'rajm@tiac.net (rajm)' wrote:
-
-
- >Hi, I am a beginer at c++, and I really need some help.
- >This is a silly question, but I can't find it in any book.
- >
- Yes it is since the answer is probably in every book about
- programming in C/C++.
-
- >I am trying to create a new file, and write some data to it, line by
- >line, as the computer asks questions of the user, like "what is your
- >name?", etc. I do not want to use a dialog box or anything like that.
- >I am jus trying to create a program in Symantec C++ 7.0.6 for the Mac
- >that can create a text file with responses in it. I do not know what
- >libraries I need nor do I know what commands are used. I REALLY need
- >help on this, so any you could give me would be GREATLY appreciated.
- >I'd be willing to do just about ANYTHING for a solution here....thanks
- >in advance.....
- >
-
- Try this, them modify to your needs.
-
- #include <iostream.h>
- #include <fstream.h>
-
- int main ()
- {
- fstream outf("test.dat", ios::out );
- cout << "Enter text lines:\n"
- "(Control-Z, followed by <Enter>, ends)" << endl;
- char line[128];
- while(cin.getline(line, 128))
- outf << line << endl;
- return 0;
- }
-
-
- >Please reply here or mail me: rajm@tiac.net
- >
- >thanks again!
- >
- >
- >
- >
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-